package com.spirit.domain.user;

import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.NumberFormat;

import javax.validation.constraints.*;
import java.util.Date;

public class User {
    @NotEmpty(message = "用户名不能为空！")
    //@NotNull 千万注意Null和Empty的区别 页面上字符串通常是""而不是null
    private String userName;
    private String passWord;
    private String confirmPassWord;
    @NotNull(message = "年龄不能为空！")
    @Range(min = 0,max = 200,message = "年龄必须是一个介于0到200之间的数字！")
    private Integer userAge;
    private String header;
    private String sessionId;
    private String userAgent;
    private Aderess aderess;
    private Integer id;
    private String gender;
    @NotEmpty(message = "邮箱不能为空！")
    @Email(message = "邮箱格式不正确！")
    private String email;
    @NotNull(message = "生日不能为空！")
    @Past(message = "生日不能大于当前日期！")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthDay;
    @NotNull(message = "工资不能为空")
    @PositiveOrZero(message = "工资必须是正数或0！")
    @NumberFormat(pattern = "###,###,###.##")
    private Float salary;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public String getConfirmPassWord() {
        return confirmPassWord;
    }

    public void setConfirmPassWord(String confirmPassWord) {
        this.confirmPassWord = confirmPassWord;
    }

    public Integer getUserAge() {
        return userAge;
    }

    public void setUserAge(Integer userAge) {
        this.userAge = userAge;
    }

    public String getHeader() {
        return header;
    }

    public void setHeader(String header) {
        this.header = header;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public String getUserAgent() {
        return userAgent;
    }

    public void setUserAgent(String userAgent) {
        this.userAgent = userAgent;
    }

    public Aderess getAderess() {
        return aderess;
    }

    public void setAderess(Aderess aderess) {
        this.aderess = aderess;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Date getBirthDay() {
        return birthDay;
    }

    public void setBirthDay(Date birthDay) {
        this.birthDay = birthDay;
    }

    public Float getSalary() {
        return salary;
    }

    public void setSalary(Float salary) {
        this.salary = salary;
    }

    public User(String userName, String passWord, Integer userAge, Integer id) {
        this.userName = userName;
        this.passWord = passWord;
        this.userAge = userAge;
        this.id = id;
    }

    public User(String userName, String passWord,Integer userAge,String gender, Aderess aderess, Integer id) {
        this.userName = userName;
        this.passWord = passWord;
        this.userAge = userAge;
        this.gender = gender;
        this.aderess = aderess;
        this.id = id;
    }

    public User() {
    }

    @Override
    public String toString() {
        return "User{" +
                "userName='" + userName + '\'' +
                ", passWord='" + passWord + '\'' +
                ", confirmPassWord='" + confirmPassWord + '\'' +
                ", userAge=" + userAge +
                ", header='" + header + '\'' +
                ", sessionId='" + sessionId + '\'' +
                ", userAgent='" + userAgent + '\'' +
                ", aderess=" + aderess +
                ", id=" + id +
                ", gender='" + gender + '\'' +
                ", email='" + email + '\'' +
                ", birthDay=" + birthDay +
                ", salary=" + salary +
                '}';
    }
}
